﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LK.Math
{
    public partial class BitsTest
    {
        static public void Log(object obj) {
            Console.WriteLine("[Bits.Test]" + obj.ToString()); ;
        }
        static public void CopyTest() {
            Log("Copy Test Start");
            Bits b1 = new Bits();
            b1.Resize(512);
            Bits b2 = new Bits();
            b2.Resize(256);
            Random r = new Random(0);
            for (int i = 0; i < 100000; ++i) {
                for (int j = 0; j < 256; ++j)
                    b1[j] = (r.Next() & 1) == 0;
                int sidx = r.Next(0, 256);
                int len = r.Next(0, 192);
                int didx = r.Next(0, b2.Length - len);
                Bits.Copy(b1.Data, sidx, len, b2.Data, didx);
                for (int j = 0; j < len; ++j)
                {
                    if (b1[sidx + j] != b2[didx + j])
                        Log("error");
                }
            }
            Log("Test Done");
        }
    }
}
